package com.service.impl;

import com.bean.entity.Dormitory;
import com.bean.entity.ManagementInfo;
import com.bean.pojo.PageAssistant;
import com.bean.vo.DormitoryVo;
import com.bean.vo.ManagementInfoVo;
import com.dao.DormitoryMapper;
import com.dao.ManagementInfoMapper;
import com.service.DormitoryService;
import com.service.ManagementInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 管理层信息基础业务逻辑实现
 */
@Service
public class ManagementInfoServiceImpl implements ManagementInfoService {

    @Autowired
    private ManagementInfoMapper managementInfoMapper;

    public int save(ManagementInfo t) throws Exception {
        return managementInfoMapper.insert(t);
    }

    public int remove(ManagementInfo t) throws Exception {
        return managementInfoMapper.delete(t);
    }

    public int modify(ManagementInfo t) throws Exception {
        return managementInfoMapper.update(t);
    }

    public ManagementInfoVo unique(ManagementInfo t) throws Exception {
        List<ManagementInfoVo> managementInfoVoList = managementInfoMapper.select(t);
        if (managementInfoVoList.size()!=1) throw new Exception("您要查询的学生分数暂未找到！");
        return managementInfoVoList.get(0);
    }

    public List<ManagementInfoVo> query(ManagementInfo t) {
        return managementInfoMapper.select(t);
    }

    public PageAssistant<ManagementInfoVo> queryByPage(Map<String, Object> map, PageAssistant<ManagementInfoVo> pa) {
        //查询并设置总记录数
        pa.setCount(managementInfoMapper.selectCount(map));
        //添加分页参数
        map.put("startCode", pa.getStartCode());
        map.put("pageSize", pa.getPageSize());
        //查询并设置页面内容
        pa.setItems(managementInfoMapper.selectByPage(map));
        return pa;
    }
}
